
package com.rx.mgt.service;  

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.rx.mgt.dao.ScheduleTaskDao;
import com.rx.mgt.domain.EmailUser;
import com.rx.mgt.domain.ScheduleTask;
import com.rx.mgt.domain.UserInfoExt;
import com.rx.mgt.po.UsersBo;

/** 
 * ClassName:ScheduleTaskService 
 * Function :
 * Reason   : 
 * Date     :Feb 6, 2017 9:30:31 AM 
 * @author   luolei 
 * @since    JDK 1.6
 */
@Service
public class ScheduleTaskService {
    @Autowired
    ScheduleTaskDao scheduleTaskDao;
    @Transactional
    public ScheduleTask get(Long id){
        return  scheduleTaskDao.get(id);
    }
    @Transactional
    public List getAllTask(UsersBo usersBo){
        return scheduleTaskDao.getAllTask(usersBo);
    }
    @Transactional
    public void delete(Long id){
        ScheduleTask scheduleTask = scheduleTaskDao.get(id);
        if(scheduleTask!=null){
            scheduleTaskDao.delete(scheduleTask);
        }
    }
    @Transactional
    public void stopTask(ScheduleTask scheduleTask){
        ScheduleTask info= scheduleTaskDao.get(scheduleTask.getId());
        if(info!=null){
            info.setStatus("N");
            scheduleTaskDao.update(info);
        }
    }
    @Transactional
    public void startTask(ScheduleTask scheduleTask){
        ScheduleTask info= scheduleTaskDao.get(scheduleTask.getId());
        if(info!=null){
            info.setStatus("Y");
            scheduleTaskDao.update(info);
        }
    }
    @Transactional
    public void  saveOrUpdate(ScheduleTask scheduleTask){
        if(scheduleTask.getId()!=null&&scheduleTask.getId()>0){
            scheduleTaskDao.update(scheduleTask);
        }else{
            scheduleTaskDao.save(scheduleTask);
        }
    }
}
  